#include <cstdio>

int graph[101][101];

int main(int argc, char const* argv[])
{
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%d", &graph[i][j]);
        }
    }

    int L = 0, S = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (graph[i][j] <= 50) {
                S++;
                if (i == 0 || i == N - 1 || j == 0 || j == N - 1)
                    L++;
                else if (graph[i - 1][j] > 50 || graph[i + 1][j] > 50 || graph[i][j - 1] > 50 || graph[i][j + 1] > 50)
                    L++;
            }
        }
    }
    printf("%d %d", S, L);

    return 0;
}